﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JMcms.Common;

namespace JMcms.Web.Plugin.Job.admin
{
    public partial class job_apply_view : JMcms.Web.UI.ManagePage
    {
        private string action = JMEnums.ActionEnum.View.ToString(); //操作类型
        protected int id = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            string _action = JMRequest.GetQueryString("action");
            if (!string.IsNullOrEmpty(_action))
            {
                this.action = JMEnums.ActionEnum.View.ToString();//查看类型
                this.id = JMRequest.GetQueryInt("id");
                if (this.id == 0)
                {
                    JscriptMsg("传输参数不正确！", "back");
                    return;
                }
                if (!new BLL.job_apply().Exists(this.id))
                {
                    JscriptMsg("信息不存在或已被删除！", "back");
                    return;
                }
            }
            if (!Page.IsPostBack)
            {
                ChkAdminLevel("plugin_job_apply_list", JMEnums.ActionEnum.View.ToString()); //检查权限
                this.id = JMRequest.GetQueryInt("id");
                if (action == JMEnums.ActionEnum.View.ToString()) //修改
                {
                    ShowInfo(this.id);
                }
            }
        }


        #region 赋值操作=================================
        private void ShowInfo(int _id)
        {
            BLL.job_apply bll = new BLL.job_apply();
            Model.job_apply model = bll.GetModel(_id);
            txtAddress.Text = model.address;
            txtAge.Text = model.age.ToString();
            txtEducation.Text = model.education;
            txtEmail.Text = model.email;
            txtJobId.Text = this.GetJob(Convert.ToInt32(model.job_id)).title;
            txtName.Text = model.title;
            txtSex.Text = model.sex;
            txtTel.Text = model.tel;

        }
        #endregion

        /// <summary>
        /// 获得职位名称
        /// </summary>
        /// <param name="id">职位Id</param>
        /// <returns></returns>
        public Model.job GetJob(int id)
        {
            BLL.job bll = new BLL.job();
            return bll.GetModel(id);
        }
    }
}